using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace kp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            dsKP.Clear();
            dsKP.ReadXml(kp.Properties.Settings.Default.dbPath);
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            dsKP.WriteXml(kp.Properties.Settings.Default.dbPath);
        }

        private void ucData1_ColumnBeforeAdd(object sender, ucData.ColumnBeforeAddEventArgs e)
        {
            if (e.DataColumn.ColumnName == "type")
                e.GridColumn = new DGVComboBoxColumn(this.dsKP, "dtEventType", "id", "desc");
            else if (e.DataColumn.ColumnName == "customer")
                e.GridColumn = new DGVComboBoxColumn(this.dsKP, "dtCustomer", "id", "desc");
            else if (e.DataColumn.ColumnName == "desc")
                e.GridColumn = new DGVTextBoxColumn(DGVTextBoxColumnStyle.Description);
        }

        private void ucData2_ColumnBeforeAdd(object sender, ucData.ColumnBeforeAddEventArgs e)
        {
            if (e.DataColumn.ColumnName == "desc")
                e.GridColumn = new DGVTextBoxColumn(DGVTextBoxColumnStyle.Description);
        }

        private void ucData4_ColumnBeforeAdd(object sender, ucData.ColumnBeforeAddEventArgs e)
        {
            if (e.DataColumn.ColumnName == "link")
                e.GridColumn = new DGVFileColumn();
        }

        private void ucData1_Load(object sender, EventArgs e)
        {

        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            //if (kp.Properties.Settings.Default.dtEvent!=null)
            kp.Properties.Settings.Default.Save();
        }
    }
}